package com.wit.witmg.api;


import com.wit.witmg.service.ITPurchaseService;
import com.wit.witmg.service.ITPurchcontrService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author bob
 * @since 2025-01-14
 */
@RestController
@RequestMapping("purchContr")
@Api(tags = "采购报价PI")
public class PurchcontrController {
    @Resource
    private ITPurchcontrService service;

    @ApiOperation("添加")
    @PostMapping("add")
    public Object add(HttpServletRequest request,
                      @RequestParam("json") String json) {
        return service.add(request,json);
    }

    @ApiOperation("获取")
    @PostMapping("get")//参数：supid、oid、pid或bn或size返回数组,pid为空时返回最近100条数据；id返回单条数据。 其中，bn和size是模糊查询
    public Object get(HttpServletRequest request,
                      @RequestParam(value = "id",required = false) Integer id,
                      @RequestParam(value = "stat",required = false) Integer stat,
                      @RequestParam(value = "supid",required = false) Integer supid,
                      @RequestParam(value = "oid",required = false) Integer oid,
                      @RequestParam(value = "pid",required = false) Integer pid,
                      @RequestParam(value = "size",required = false) String size,
                      @RequestParam(value = "bn",required = false) String bn)
    {
        return service.get(request,id,stat,supid,oid,pid,size,bn);
    }

    @ApiOperation("删除")
    @PostMapping("del")
    public Object del(HttpServletRequest request,
                      @RequestParam("id") Integer id) {
        return service.del(request,id);
    }
}
